package com.ask.javabagubooster.a_java_basis.juc.lock;

import java.util.LinkedList;
import java.util.List;

public class ShoppingCart {
    private final List<String> cart = new LinkedList<>();
    public synchronized void add(String good){
        System.out.println("添加商品至购物车...");
        cart.add(good);
    }

    public void show() {
        for (String s : cart) {
            System.out.println(s);
        }
    }
}
